<script>
    // 使用outerHTML属性获取整个table元素的HTML代码（包括<table>标签），然后包装成一个完整的HTML文档，设置charset为urf-8以防止中文乱码
    var html = "<html><head><meta charset='utf-8' /></head><body>" + document.getElementById("report_design_render_table").outerHTML + "</body></html>";
    // 实例化一个Blob对象，其构造函数的第一个参数是包含文件内容的数组，第二个参数是包含文件类型属性的对象
    var blob = new Blob([html], {type: "application/vnd.ms-excel"});
    var a = document.getElementById("report_design_render_export");
    // 利用URL.createObjectURL()方法为a元素生成blob URL
    a.href = URL.createObjectURL(blob);
    // 设置文件名
    a.download = "报表.xls";
</script>
<style>
    #report_design_render_table .table th, #report_design_render_table .table td {
        text-align: center;
        vertical-align: middle !important;
    }
</style>
<div th:fragment="copy" style="padding: 0 12px 12px 12px;" id="report_design_render_table">

    <div class="row" style="margin-top: 12px;">
        <div class="col-xs-12">
            <table border="1" class="table table-hover table-bordered table-striped">
                <thead>
                <tr>
                    <th th:rowspan="${bo.getDimensionValueList() == null ? 1 : 2}"
                        th:each="layout : ${bo.getLayoutColumnList()}"
                        th:text="${layout.title}"></th>
                    <th:block th:if="${bo.getDimensionValueList().size()} != 0">
                        <th th:colspan="${bo.getStatisticsColumnList().size()}"
                            th:each="dimension : ${bo.getDimensionValueList()}"
                            th:text="${dimension}"></th>
                    </th:block>
                    <th:block th:if="${bo.getDimensionValueList().size()} == 0">
                        <th th:each="statistics : ${bo.getStatisticsColumnList()}"
                            th:text="${statistics.title}"></th>
                    </th:block>
                </tr>
                <tr>
                    <th:block th:if="${bo.getDimensionValueList().size()} != 0">
                        <th:block th:each="dimension : ${bo.getDimensionValueList()}">
                            <th th:each="statistics : ${bo.getStatisticsColumnList()}"
                                th:text="${statistics.title}"></th>
                        </th:block>
                    </th:block>

                </tr>
                </thead>
                <tbody>
                <tr th:each="item : ${bo.getGroupColumnDataList()}">
                    <th:block th:each="map : ${item}">
                        <!--如果存在维度列-->
                        <th:block th:if="${bo.getDimensionValueList().size()} != 0">
                            <th:block th:if="${map.key} != ''" th:each="subItem : ${map.key.split(',')}">
                                <td th:text="${subItem}"></td>
                            </th:block>
                            <th:block th:each="subItem : ${map.value}">
                                <th:block th:each="statisticsMap : ${subItem}">
                                    <!--维度列-->
                                    <th:block th:each="dimension : ${bo.getDimensionValueList()}">
                                        <th:block th:if="${statisticsMap.key eq dimension}">
                                            <th:block th:each="statisticsColumnMap : ${statisticsMap.value}">
                                                <!--统计列-->
                                                <th:block th:each="statistics : ${bo.getStatisticsColumnList()}">
                                                    <td th:text="${statisticsColumnMap.get(statistics.name)}"></td>
                                                </th:block>
                                            </th:block>
                                        </th:block>
                                    </th:block>
                                </th:block>
                            </th:block>
                        </th:block>
                        <!--如果不存在维度列-->
                        <th:block th:if="${bo.getDimensionValueList().size()} == 0">
                            <th:block th:each="subItem : ${map.key.split(',')}">
                                <td th:text="${subItem}"></td>
                            </th:block>
                            <!--统计列-->
                            <th:block th:each="subItem : ${map.value}">
                                <th:block th:each="statisticsMap : ${subItem}">
                                    <th:block th:each="statisticsColumnMap : ${statisticsMap.value}">
                                        <!--统计列-->
                                        <th:block th:each="statistics : ${bo.getStatisticsColumnList()}">
                                            <td th:text="${statisticsColumnMap.get(statistics.name)}"></td>
                                        </th:block>
                                    </th:block>
                                </th:block>
                            </th:block>
                        </th:block>
                    </th:block>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
